package com.mode.mvp.joke;

import com.mode.mvp.bean.Joke;
import com.mode.mvp.listener.OnMVPListener;

public class JokePresenter extends JokeContract.JokePresenter {

    @Override
    public void requestJoke(String pNum, String pSize) {
        final JokeContract.JokeView mView = getView();
        if(mView==null){
            return;
        }
        mView.showLoading();

        mModel.requestJoke(pNum, pSize, new OnMVPListener<Joke>() {
            @Override
            public void onSuccess(Joke pJoke) {
                mView.hideLoading();
                mView.setJoke(pJoke);
            }

            @Override
            public void onError() {
                mView.hideLoading();
                mView.showError();
            }
        });
    }
}
